package com.zzjson.serial;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2020 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.serial</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2020年02月19日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class SocketClientCustomer {
	public static void main(String[] args) {
		User user = new User();
		user.setName("zzy");
		user.setAge(19);
		ObjectOutputStream objectOutputStream = null;
		Socket socket = null;
		try {
			socket = new Socket("127.0.0.1", 8080);
			objectOutputStream = new ObjectOutputStream(socket.getOutputStream());
			objectOutputStream.writeObject(user);

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (objectOutputStream != null) {
					objectOutputStream.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (socket != null) {
				try {
					socket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
